package appapi.service.impl;

import appapi.Request.SelfItemReq;
import appapi.service.SelfCheckItemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import appapi.dao.SelfcheckitemMapper;
import appapi.entity.basic.SelfcheckItemEntity;

import java.util.List;

/**
 * 请求对象
 *
 * @author luocheng
 * @version 1.0
 * @date 2023/05/25 13:40
 */
@Service
public class SelfcheckitemServiceImpl extends ServiceImpl<SelfcheckitemMapper, SelfcheckItemEntity> implements SelfCheckItemService {

    @Resource
    private SelfcheckitemMapper selfcheckitemMapper;

    @Override
    public List<SelfcheckItemEntity> list(SelfItemReq req) {
        return selfcheckitemMapper.selectList(req);
    }

    @Override
    public SelfcheckItemEntity detail(Long selfItemId) {
        return selfcheckitemMapper.selectDetail(selfItemId);
    }

    @Override
    public int count(SelfcheckItemEntity entity) {
        return selfcheckitemMapper.count(entity);
    }

    @Override
    public int insert(SelfcheckItemEntity entity) {
        return selfcheckitemMapper.insertInfo(entity);
    }

    @Override
    public int update(SelfcheckItemEntity entity) {
        return selfcheckitemMapper.updateInfo(entity);
    }

    @Override
    public int delete(Long selfItemId) {
        SelfcheckItemEntity entity =selfcheckitemMapper.selectDetail(selfItemId);
        if(entity==null)
        {
            return  -2;
        }
        int iRet = selfcheckitemMapper.allowDelete(entity.getItemName());
        if(iRet>0)
        {
            return  -1;
        }
        return selfcheckitemMapper.deleteInfo(selfItemId);
    }
}
